<template>
	<div>
		<el-transfer :data="adminList" :props="props" :titles="titles" v-model="values"></el-transfer>
		<el-button style="margin-top: 10px;" type="primary" plain @click="save">保存</el-button>
	</div>
</template>

<script setup>
import { get,post } from '@/plugins/axios'
import { reactive, ref } from 'vue';
const prop = defineProps(['roleId'])
const emits = defineEmits(['update:show'])

const adminList = ref([])
const props = reactive({
	label: 'username',
	key: 'id'
})

const titles = reactive(['未选用户','已选用户'])
const values = ref([])

function getAdminList(){
	get('/userRole/getUser',{roleId: prop.roleId},content => {
		console.log(content)
		adminList.value = content.userList
		for (const i in content.userRoleList) {
			values.value.push(content.userRoleList[i].userId)
		}
		console.log(values.value)
	})
}

function save(){
	 post('/userRole/save',{ roleId: prop.roleId, userIds: values.value }, content => {
		emits('update:show', false)
	 })
}

getAdminList()
</script>

<style>
</style>